<html>

<head>
    <meta charset="utf-8" />
    <title>响应式CSS Gride布局</title>
    <style>
        html, body{
            margin: 0;
            padding: 0;
        }
        .wapper1{
            display: grid;
            
            grid-template-columns: 1fr 1fr 1fr 1fr;
            grid-template-rows: 1fr 2fr;

            grid-column-gap: 1px;
            grid-row-gap: 1px;

            background-color: black;
            height: 300px;
        }
        .wapper2{
            display: grid;
            
            grid-template-columns: repeat(4, 1fr);
            grid-template-rows: 1fr 1fr 1fr;

            grid-column-gap: 10px;
            grid-row-gap: 10px;

            background-color: black;
            height: 300px;
        }
        @media screen and (max-width: 800px) {
            div.wapper1{
                grid-template-columns: 1fr 1fr 1fr;
                grid-template-rows: 1fr 2fr;
            }
        }
        @media screen and (max-width: 600px) {
            div.wapper1{
                grid-template-columns: 1fr 1fr;
                grid-template-rows: 1fr 2fr;
            }
        }
        @media screen and (max-width: 400px) {
            div.wapper1{
                grid-template-columns: 1fr;
                grid-template-rows: 1fr 1fr 1fr 1fr;
            }
        }
        .letter{
            display: flex;
            justify-content: center;
            align-items: center;

            background-color: #39F;
            font-size: 50px;
        }
        .wapper2>div:nth-child(1) {
            grid-area: 1 / 1 / 4 / 2;
        }
        .wapper2>div:nth-child(2) {
            grid-area: 1 / 2 / 2 / 4;
        }
        .wapper2>div:nth-child(3) {
            grid-area: 1 / 4 / 2 / 5;
        }
        .wapper2>div:nth-child(4) {
            grid-area: 2 / 2 / 4 / 5;
        }
    </style>
</head>

<body>
    <h3>CSS Grid 弹性布局</h3>
    <div class="wapper1">
        <div class="letter">A</div>
        <div class="letter">B</div>
        <div class="letter">C</div>
        <div class="letter">D</div>
    </div>
    <h3>CSS Grid 合并单元格</h3>
    <div class="wapper2">
        <div class="letter">A</div>
        <div class="letter">B</div>
        <div class="letter">C</div>
        <div class="letter">D</div>
    </div>
</body>

</html>